package lei.h_java8特性.lambda表达式;

/**
 * @className: LambdaExample02
 * @author: xl
 * @date: 2025/3/1 15:47
 * @Version: 1.0
 * @description:
 */

// 自定义函数式接口
@FunctionalInterface
interface Greeting {
    void sayHello(String name);
}

public class LambdaExample02 {
    public static void main(String[] args) {
        // 使用 Lambda 表达式实现自定义接口
        Greeting greeting1 = (name) -> System.out.println("Hello, " + name + "!");

        Greeting greeting2 = name-> System.out.println("Hello, " + name + "!");

        //greeting1.sayHello("Alice"); // 输出: Hello, Alice!


    }
}

